package com.ihomey.linkuphome.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by Administrator on 2016/10/22.
 */


public class CustomViewpager extends ViewPager {

    private boolean isScrollable = true;

    public CustomViewpager(Context context) {
        super(context);
    }

    public CustomViewpager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return this.isScrollable && super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return this.isScrollable && super.onInterceptTouchEvent(event);
    }

    public void setScrollable(boolean isScrollable) {
        this.isScrollable = isScrollable;
    }

//    @Override
//    public void setCurrentItem(int item, boolean smoothScroll) {
//        super.setCurrentItem(item, smoothScroll);
//    }
//
//    @Override
//    public void setCurrentItem(int item) {
//        super.setCurrentItem(item, false);//表示切换的时候，不需要切换时间。
//    }
}
